package com.wteam.modules.system.util;

import org.paukov.combinatorics3.Generator;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class RandomUtil {
    public static String getRandomString(int length){
        String str="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<length;i++){
            int number=random.nextInt(26);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }

    public static <T> List<List<T>> combination(List<T> list,Integer length){
        return Generator.combination(list)
                .simple(length)
                .stream()
                .collect(Collectors.toList());
    }

    public static void genEsMethodName(Map<String,String> params){
        List<List<Integer>> combination = new LinkedList<>();
        List<Integer> numList = new LinkedList<>();
        Map<Integer, Map.Entry<String,String>> data = new HashMap<>();
        Integer idx = 1;
        for (Map.Entry<String, String> entry: params.entrySet()){
            data.put(idx,entry);
            numList.add(idx++);
        }


        for (int i = 1; i <= params.size();i++){
            combination.addAll(combination(numList,i));
        }

        System.out.println(combination);;

    }

    public static void main(String[] args) {
        Map<String,String> param = new HashMap<>();
        param.put("String Name","Like");
        param.put("Long TypeId","");
        param.put("Double Credit","Between");
        param.put("Boolean Compulsory","");
        param.put("Long Id","");
        param.put("String Code","Like");

        RandomUtil.genEsMethodName(param);
    }

}
